// 小汽车
interface ICar {
  name: string;
  length: number;
  run(): void;
}
//货车
interface ITruck {
  name: string;
  length: number;
  laHuo(): void;
}
// 接口和接口: 多继承
interface Che extends ITruck, ICar {}

// 类和接口: 多实现
class Byd implements ICar, ITruck {
  public a: number = 3; //本类和子类都可以访问
  protected b: number = 4; //本类内部和子类的内部使用
  private c: number = 5; //本类的内部可以访问
  readonly d: number = 6;
  name: string = "唐";
  length: number = 3;
  run(): void {
    console.log("跑高速");
    console.log(this.c);
    console.log(this.b);
  }
  laHuo(): void {
    console.log("拉货");
  }
}
// 本类内部可以访问所有成员
// let byd: Byd = new Byd();
// console.log(byd.a);
// // console.log(byd.b);
// // console.log(byd.c);
// // byd.d = 8;
// console.log(byd.d);
// byd.run();

// 类和类: 单继承
class Byd2 extends Byd {
  name: string = "唐2";
  length: number = 3;
  run(): void {
    console.log(this.a);
    console.log(this.b);
    // console.log(this.c);
    console.log(this.d);
    console.log("跑高速");
  }
  laHuo(): void {
    console.log("拉货");
  }
  automaticDrive() {
    console.log("自动驾驶");
  }
}
let byd2 = new Byd2();
console.log(byd2);
byd2.run();
console.log(byd2.a);
// console.log(byd2.b);
// console.log(byd2.c);
// console.log(byd2.d);

class DongFeng implements ITruck {
  name: string = "东方1型";
  length: number = 23;
  laHuo(): void {
    console.log("拉货");
  }
}
// let b: Byd = new Byd();
// let d: DongFeng = new DongFeng();
// console.log(b);
// console.log(d);

// let b2: Byd2 = new Byd2();
// console.log(b2);
// b2.laHuo();
// b2.run();
// b2.automaticDrive();

// let b3: ICar = new Byd2();
// console.log(b3);
// b3.run();
